<extend name="Public/base" />

<block name="style">
<link href="__STATIC__/imgtip/css/img-tip.css" rel="stylesheet"
	type="text/css">
<link rel="stylesheet" type="text/css"
	href="__STATIC__/qtip/jquery.qtip.min.css" media="all">
<script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script> <script
	type="text/javascript" src="__STATIC__/qtip/jquery.qtip.min.js"></script>
</block>

<block name="body"> <!-- 标题栏 -->
<div class="main-title">
	<h2>附件管理</h2>
</div>
<div class="cf">
	<div class="fl">
		<a class="btn"
			href="{:U('addtext',array('question'=>$question['id']))}">新增文本</a> <a
			class="btn"
			href="{:U('addimage',array('question'=>$question['id']))}">新增图表</a>
		<lable class="btn"
			title="{$question['questiontype']|get_questiontype_name}"
			value="{$question['title']}">预览题目</lable>
		<a class="btn" href="{:U('Questions/index?itembank='.$question['itembank'])}">返回试题</a>
	</div>
	<!-- 高级搜索 -->
	<div class="search-form fr cf">
		<div class="sleft">
			<input type="text" name="title" class="search-input" value=""
				placeholder="请输入文本内容筛选"> <a class="sch-btn"
				href="javascript:;" id="search" url=""><i class="btn-search"></i></a>
		</div>

	</div>
</div>

<div class="data-table table-striped">
	<table>
		<thead>
			<tr>
				<th class="row-selected row-selected"><input class="check-all"
					type="checkbox" /></th>
				<th style="width: 5%">序号</th>
				<th style="width: 30%">文本</th>
				<th style="width: 30%">图表</th>
				<th>空行</th>
				<th>排序</th>
				<th>类别</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			<notempty name="questionattachments"> <assign name="i"
				value="1" /> <volist name="questionattachments" id="vo">
			<tr>
				<td><input class="ids" type="checkbox" name="id[]"
					value="{$vo.id}" /></td>
				<td>{$i}</td>
				<td>{$vo.text}</td>
				<td><if condition="$vo.type eq 0"> <a href="#"><img
						class="tip" alt="" src="{$vo.image}"></a></if></td>
				<td>{$vo.answer_rows}</td>
				<td>{$vo.order}</td>
				<td><if condition="$vo.type eq 0">图表<else />文本</if></td>
				<td><a title="编辑" href="{:U('edit?id='.$vo['id'])}">编辑</a> <a class="confirm ajax-get"
					title="删除" href="{:U('del',array('question'=>$question['id'],'id'=>$vo['id']))}">删除</a></td>
				<assign name="i" value="$i++" />
			</tr>
			</volist> <else />
			<td colspan="9" class="text-center">暂时还没有内容!</td>
			</notempty>
		</tbody>
	</table>
</div>
<div class="page">{$_page}</div>
</block>

<block name="script"> <script type="text/javascript">
+function($){
	$('.tip').mouseover(function(){
	      var $tip=$('<div id="tip"><div class="t_box"><div><s><i></i></s><img src="'+this.src+'" /></div></div></div>');
	      $('body').append($tip);
	      $('#tip').show('fast');
	   }).mouseout(function(){
	      $('#tip').remove();
	   }).mousemove(function(e){
	      $('#tip').css({"top":(e.pageY-60)+"px","left":(e.pageX+30)+"px"});
	   });
	//预览题目
	$('.btn').each(function(){
        $(this).qtip({
            content: {
                text: $(this).attr('value'),
                title: $(this).attr('title')
            },
            position: {
                my: 'top center',
                at: 'bottom center',
                target: $(this)
            },
            style: {
                classes: 'qtip-green',
                tip: {
                    corner: true,
                    mimic: false,
                    width: 5,
                    height: 5
                }
            }
        });
    });
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
    //导航高亮
    $('.side-sub-menu').find('a[href="{:U('ItemBank/myitems')}"]').closest('li').addClass('current');
}(jQuery);
</script> </block>
